

//点击供应商菜单
function supplierBaseInfoPrice(){
	//获取显示信息列表内容
	//var clientInfo = getClientInfo();
	var clientList = $("#bag").html("");
	clientList.load("showSupplierPrice",function(response,status,xhr){
		var data = "supplierQuotaNo="+"&currentPages=";
		//调用显示客户列表信息的方法
		showSupplierInfoPrice(data);
	})

		
}

//按条件查询客户基本信息
function supplierSelPrice(){
	//获取查询条件
	var data="supplierQuotaNo="+$("#supplierNamesPrice").val()+"&currentPages=";
	showSupplierInfoPrice(data);
}



//获取客户基本信息
function getClientAll(){
	var va =$("#sClientInfo").html("");
	//获取提交路径
	var url="/trade-wzj-web/ClientContrillerYang/clientSel";
	var $data = "name=&currentPages=";
	var result = postMethod(url,"POST",$data);
	var r=result.list;

	var str="<option value=0>--请选择客户信息--</option>";
	$("#choiceClient").html("");
	for(var i=0;i<r.length;i++){
		str=str+"<option value='"+r[i].clientInfoID+"'>" +
					r[i].clientName+
				"</option>";
		
	}
	$("#choiceClient").append(str);
}

//显示供应商报价基本信息
function showSupplierInfoPrice($data){
	var tbody = $("#supplierPriceTables tbody").html("");
	var result = postMethod("/trade-wzj-web/Supplier_quotaController_Yang/getAllSupplierQuotas","POST",$data);
	
	var list=result.list;

	var str="";
	//获取查询条件
	var selCondition = $("#supplierNamesPrice").val();
	if(list.length>=0){
		for(var i=0;i<list.length;i++){
			str = str+"<tr>"+
    		"<td>"+list[i].supplierquotaID+"</td>"+
    		"<td>"+list[i].supplierInfo.supplierName+"</td>"+
    		"<td>"+list[i].quotaDate+"</td>"+
    		"<td>"+list[i].state.payStateName+"</td>"+
    		"<td>"+list[i].remark+"</td>"+
    		"<td><a href='#' onclick='searchSupplierPrice(\""+list[i].supplierquotaID+"\");'><span class='glyphicon glyphicon-search'></span></a>&nbsp;&nbsp;<a href='#' onclick='updateSupplierPriceOpen(\""+list[i].supplierquotaID+"\",\""+selCondition+"\");'><span class='glyphicon glyphicon-pencil'></span></a>&nbsp;&nbsp;<a href='#' onclick='delSupplierTablePrice("+list[i].clientInfoID+",\""+selCondition+"\")'><span class='glyphicon glyphicon-remove'></span></a></td>"+
    		"</tr>";
		}
	}
	tbody.append(str);
	var page = getPageSupplierPrice(result);
	var pageTable = $("#supplierPricefoot").html("");
	
	pageTable.append(page);
}

//获取页码信息
function getPageSupplierPrice($clientList){
	var page="";
	var con = $("#supplierNamesPrice").val();
	page = page+"<div class='row' style='margin:0px'>" +
	"<div class='col-md-2 col-sm-2 col-xs-2' style='padding-top:0.7rem'>"+
		"<span style='font-weight:bold'>总记录数 "+$clientList.total+"   |  总页数 "+$clientList.pages+"</span>"+
	"</div>"+
	"<div class='col-md-offset-8 col-sm-offset-8 col-xs-offset-8'>"
	+"<nav aria-label='Page navigation'>"+
"<ul class='pagination pagination-sm'>";
	if($clientList.prePage>0){
		page = page+"<li><a href='#' onclick='getPagesSupplierPrice("+$clientList.firstPage+",\""+con+"\")'>首页</a></li>"+
		"<li><a href='#' onclick='getPagesSupplierPrice("+$clientList.prePage+",\""+con+"\")'>上一页</a></li>";
				
	}
	if($clientList.nextPage<=$clientList.lastPage && $clientList.nextPage>0){
		page = page+"<li><a href='#' onclick='getPagesSupplierPrice("+$clientList.nextPage+",\""+con+"\")'>下一页</a></li>"+
		"<li><a href='#' onclick='getPagesSupplierPrice("+$clientList.lastPage+",\""+con+"\")'>末页</a></li>";
	}
	page = page+"</li>"+
"</ul>"+
"</nav>"+
"</div>"+
"</div>";
	return page;
	
}

//分页功能
function getPagesSupplierPrice($page,$object){
	var data="supplierQuotaNo="+$object+"&currentPages="+$page;
	showSupplierInfoPrice(data);
}


//删除供应商基本信息
function delSupplierTablePrice($delId,$pageNum,$object){
	var ensure = confirm("确定删除此信息吗?");
	
	if(ensure==false){
		return;
	}
	//获取删除条件
	var data="clientInfoId="+$delId;
	var url="/trade-wzj-web/testYu/test";
	var result = postMethod(url,"POST",data);
	if(result==""){
		alert("删除成功!");
	}else{
		alert(result);
	}
	
	var selData = "name="+$object+"&currentPages="+$pageNum;
	showSupplierInfoPrice(selData);
}




//新增客户基本信息
function addSupplierPrice(){
	var tables = $("#addSupplierTablePrice");
	tables.html("");
	var tableAdd = "<tr>" +
			"<td>报价编号*：</td>" +
			"<td><input type='text' class='form-control' datatype='*' nullmsg='此信息不能为空' name='clientName' ></td>"+
			"<td></td>"+
			"</tr>"+
			"<tr>" +
			"<td>供应商名称*：</td>" +
			"<td><input type='text' class='form-control' datatype='*' nullmsg='不能为空' name='clientContacts'></td>"+
			"<td></td>"+
			"</tr>"+
			"<tr>" +
			"<td>报价日期*：</td>" +
			"<td><input type='text' name='clientPhone' datatype='*' nullmsg='不能为空'  class='form-control'></td>"+
			"<td></td>"+
			"</tr>"+
			"<tr>" +
			"<td>报价截止日期*：</td>" +
			"<td><input type='text' name='clientEmail' datatype='*' nullmsg='不能为空' class='form-control'></td>"+
			"<td></td>"+
			"</tr>"+
			"<tr>" +
			"<td>付款条件*：</td>" +
			"<td><input type='text' name='clientAddress' datatype='*' nullmsg='客户地址不能为空' class='form-control'></td>"+
			"<td></td>"+
			"</tr>"+
			"<tr>" +
			"<td>备注*：</td>" +
			"<td><input type='text' name='clientEmail' datatype='*' nullmsg='不能为空' class='form-control'></td>"+
			"<td></td>"+
			"</tr>"+
			
	tables.append(tableAdd);
	$("#addSupplierPriceModal").modal("toggle");
}

//保存客户基本信息添加
function saveSupplierPrice(){
	var addClientForm = $("#addSupplierPriceForm").Validform({
		tiptype:1
	});
	
	var bool = addClientForm.check();
	if(bool==false){
		$("#addSupplierPriceS").popover("toggle");
		return;
	}
	var data = $("#addSupplierPriceForm").serialize();
	//获取提交路径
	var url="/trade-wzj-web/tests/gyslbAdd";
	var flag = postMethod(url,"POST",data);
	
	if(flag==""){
		alert("添加成功!");
		
	}else{
		alert("添加失败");
	}
	showSupplierInfoPrice(null);
}

//打开要修改的供应商报价列表信息页面
function updateSupplierPriceOpen($updateId,$object,$num){
	//定义要修改的对象
	var data="updateId="+$updateId+"&name="+$object+"&num="+$num;
	//获取提交路径
	var url="";
	//调用提交方法
	var result = postMethod(url,"POST",data);
	var tables = $("#updateSupplierPriceTable").html("");
	
	var tableAdd = "<tr>" +
			"<td>报价编号*：</td>" +
			"<td><input type='text' class='form-control' readonly='readonly' value='"+result.clientName+"'><input type='hidden' value='"+result.id+"'></td>"+
			"<td></td>"+
			"</tr>"+
			"<tr>" +
			"<td>供应商名称*：</td>" +
			"<td><input type='text' class='form-control' datatype='*' nullmsg='不能为空' name='clientContacts' value='"+result.clientContacts+"' required></td>"+
			"<td></td>"+
			"</tr>"+
			"<tr>" +
			"<td>报价日期*：</td>" +
			"<td><input type='text' name='clientPhone' datatype='n11' errormsg='号码有误!' class='form-control' value='"+result.clientPhone+"' required></td>"+
			"<td></td>"+
			"</tr>"+
			"<tr>" +
			"<td>报价截止日期*：</td>" +
			"<td><input type='text' value='"+result.clientAddress+"' name='clientAddress' datatype='*' class='form-control' required></td>"+
			"<td></td>"+
			"</tr>"+
			"<tr>" +
			"<td>付款条件*：</td>" +
			"<td><input type='text' value="+result.clientEmail+" name='clientEmail' datatype='*' class='form-control' required></td>"+
			"<td></td>"+
			"</tr>"+
			"<tr>" +
			"<td>备注*：</td>" +
			"<td><input type='text' value='"+result.clientFax+"' name='clientFax' datatype='*' class='form-control' required></td>"+
			"<td></td>"+
			"</tr>";
	tables.append(tableAdd);
	$("#updateSupplierPriceModal").modal("toggle");
}

//修改客户基本信息按钮方法
function updateSupplierPrice(){
	
	var updateClientForm = $("#updateSupplierPriceForm").Validform({
		tiptype:1
	});
	var bool = updateClientForm.check();
	if(!bool){
		$("#updateSupplierPriceS").popover("toggle");
		return;
	}
	var formData = $("#updateSupplierPriceForm").serialize();
	//获取提交路径
	var url="/trade-wzj-web/test/updateSupplierPrice";
	var result = postMethod(url,"POST",data);
	var $data="";
	showSupplierInfoPrice($data);
}
